<template>
  <!-- <div id="app"> -->
  <!-- <router-link to="/index">首页</router-link>
    <router-link to="/shouru">收入</router-link>
    <router-view></router-view> -->
  <el-container>

    <!---主体部分--->
    <el-container>
      <!---左侧导航--->
      <el-aside style="text-align:left"
                :width="isCollapse ? '64px' : '200px'">
        <div class="header">
          <router-link :to="{ path: '/home' }"><img src="../assets/logo.png"
                 alt=""><span class="title">大华加油系统</span></router-link>
        </div>
        <el-menu router
                 unique-opened
                 :collapse="isCollapse">
          <!---收入--->
          <el-submenu index="4"
                      :default-openeds="['1']">
            <template slot="title">
              <!-- 图标 -->
              <i class="el-icon-coin"></i>
              <!-- 文本 -->
              <span>收入情况</span>
            </template>
            <el-menu-item index="/shouru">
              <!-- 二级菜单模板 -->
              <template>
                <!-- 图标 -->
                <i class="iconfont icon-pianyuansanhu"></i>
                <!-- 文本 -->
                <span>散户</span>
              </template>
            </el-menu-item>

            <el-menu-item index="/cards">
              <template>
                <i class="iconfont icon-shenghuochongyouqia"></i>
                <span>油卡</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/customlist">
              <template>
                <i class="iconfont icon-customer1"></i>
                <span>会员</span>
              </template>
            </el-menu-item>
          </el-submenu>
          <!---销售情况--->
          <el-submenu index="2"
                      :default-openeds="['/oil']">
            <template slot="title">
              <!-- 图标 -->
              <i class="el-icon-male"></i>
              <!-- 文本 -->
              <span>销售情况</span>
            </template>
            <el-menu-item index="/oil">
              <!-- 二级菜单模板 -->
              <template>
                <!-- 图标 -->
                <i class="iconfont icon-shenghuochongyouqia"></i>
                <!-- 文本 -->
                <span>柴油</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/urea1">
              <template>
                <i class="iconfont icon-niaosu"></i>
                <span>尿素</span>
              </template>
            </el-menu-item>
          </el-submenu>
          <!------系统管理---->
          <el-submenu index="10">
            <template slot="title">
              <i class="el-icon-setting"></i>
              <span>系统管理</span>
            </template>
            <el-menu-item index="/member">
              <template>
                <i class="iconfont icon-huiyuanguanli"></i>
                <span>会员管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/shouruManage">
              <template>
                <i class="iconfont icon-shouruguanli"></i>
                <span>收入管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/xiaoshou">
              <template>
                <i class="iconfont icon-xiaoshouguanli"></i>
                <span>销售管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/users">
              <template>
                <i class="iconfont icon-yonghuguanli_huaban"></i>
                <span>用户管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/shuju">
              <template>
                <i class="iconfont icon-zhushujuguanlixitong"></i>
                <span>数据管理</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!--右侧内容展示--->
      <el-main>

        <el-header>
          <!-- <div>
            <router-link :to="{ path: '/home' }"><img src="../assets/logo.png"
                   alt=""><span class="title">大华加油管理系统</span></router-link>
          </div> -->
          <div class="toggle-button "
               @click="toggleCollapse"><i class="iconfont icon-bars"></i></div>
          <div>
            <router-link to="/addData"
                         class="rl el-button el-button--info">数据录入</router-link>
            <el-button type="info"
                       @click="logout">退出</el-button>
          </div>
        </el-header>

        <router-view></router-view>
      </el-main>
    </el-container>
    <el-footer>版权信息</el-footer>
  </el-container>
</template>
<script>
// import Data from './components/Data.vue'
export default {
  name: 'Home',
  // components: {
  //   Data
  // }
  data () {
    return {
      activePath: '',
      isCollapse: true,
      isChange: false
    }
  },
  created () {
    this.changeRoute()
  },
  methods: {
    //退出
    logout () {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    // 点击按钮，切换菜单的折叠与展开
    toggleCollapse () {
      this.isCollapse = !this.isCollapse
    },
    _isMobile () {
      let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
      return flag;
    },
    changeRoute () {
      if (this._isMobile()) {
        // alert("手机端");
        // this.$router.push('panel')
        this.isCollapse = true
        // this.$router.replace('/m_index');
      } else {
        this.isCollapse = false
        // alert("pc端");
        // this.$router.replace('/pc_index');
      }
    }
  }
}
</script>
<style>
* {
  margin: 0;
  padding: 0;
}
.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #fff;
  font-size: 16px;
  white-space: nowrap;
  margin-bottom: 20px;
}
.el-header a {
  color: #fff;
  text-decoration: none;
}
.el-card {
  padding-top: 20px;
}
.el-header > div {
  display: flex;
  align-items: center;
}
.el-header > div img {
  width: 20px;
  height: 20px;
}
.el-header > div span.title {
  margin-left: 15px;
}

.el-footer {
  background: #373d41;
  line-height: 60px;
  color: #fff;
}
.el-container {
  min-height: 100%;
  /* background: #eee; */
  background: #e3e6ea;
  min-width: 100%;
}
.el-aside {
  background: #333744;
}
.el-aside > div.header img {
  width: 20px;
  height: 20px;
  margin-right: 20px;
}
.el-aside > div.header a {
  color: #fff;
  text-decoration: none;
}
.el-aside > div.header {
  padding: 25px;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
}
.el-aside .el-menu {
  background: #333744;
  color: #fff;
  border: none;
}
.el-submenu__title,
.el-menu-item {
  color: #fff;
}

.el-main {
  background: #e3e6ea;
  overflow: hidden;
  height: 100%;
}
.el-menu-item:hover {
  outline: 0;
  background-color: #666;
}
.el-submenu__title:hover {
  background-color: #666;
}
.el-submenu__title:hover {
  outline: 0;
  background-color: #666;
}
.el-dropdown-menu__item:not(.is-disabled):hover {
  background-color: #666;
  color: #66b1ff;
}
.el-container .el-aside {
  overflow: hidden;
}
.toggle-button {
  background-color: #409eff;
  font-size: 20px;
  line-height: 30px;
  color: #fff;
  text-align: center;
  /* letter-spacing: 0.2em; */
  cursor: pointer;
  height: 30px;
  border-radius: 5px;
  letter-spacing: 0;
  padding: 0 15px;
}

.toggle-button {
  /* width: 50px; */
  /* background: #409eff; */
  /* height: 30px; */
  /* text-align: center; */
}
.el-menu--vertical .el-menu {
  background: #666;
}
.el-menu--vertical .el-menu li:hover {
  color: #66b1ff;
}
.el-row.excel {
  padding-top: 20px;
  text-align: right;
}
.rl {
  text-decoration: none;
}

.el-breadcrumb {
  background: #fff;
  margin-bottom: 20px;
  /* width: 100%; */
  height: 70px;
  line-height: 70px;
  font-size: 18px;
  padding-left: 20px;
  /* text-indent: 20px; */
}
.toggle-button .iconfont {
  margin-right: 0;
}
.el-card {
  margin: 20px;
  padding: 0;
}
</style>
